using UnityEngine;
using QFramework;
using System.Linq;
using System;

namespace ProjectSurvivor
{
    public partial class Bomb : GamePlayObject
    {
        protected override Collider2D Collider2D => SelfCircleCollider2D;

        public static void Excute()
        {
            foreach (var item in FindObjectsByType<Enemy>(FindObjectsInactive.Exclude, FindObjectsSortMode.None))
            {
                DemageSystem.CalculateDemage(Global.BombDemage.Value, item);
            }
            AudioKit.PlaySound("Bomb");
            CameraController.Shake();
            UIGamePanel.FlashScreen.Trigger();
        }

        private void OnTriggerEnter2D(Collider2D collision)
        {
            if (collision.GetComponent<CollectableArea>())
            {
                Excute();
            }
        }
    }
}
